package com.dingding.dao.usermangerdao.impl;

import java.math.BigDecimal;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.dingding.bean.databean.request.ReqUserLoginByNum;
import com.dingding.bean.databean.request.ReqUserRegister;
import com.dingding.bean.entity.Userintegral;
import com.dingding.dao.basedao.impl.BaseDaoImpl;
import com.dingding.dao.usermangerdao.IUserIntegralDao;

public class UserIntegralDaoImpl extends BaseDaoImpl<Userintegral> implements IUserIntegralDao{

	/**
	 * @Title: saveUserIntegral
	 * @Description: 保存到用户账户表
	 * @param reqUserRegister
	 *            -用户注册请求bean
	 * @param userIntegralId
	 *            -账户id
	 * @param userLoginId
	 *            -登录id
	 * @param @return
	 * @author Li Yi
	 * @return
	 * @throws
	 */
	public void saveUserIntegral(ReqUserRegister reqUserRegister,
			String userIntegralId, String userLoginId) {

		Userintegral userintegral = new Userintegral();
		// 为用户账户表设置主键
		userintegral.setUsId(userIntegralId);
		// 用户登录ID
		userintegral.setLoginId(userLoginId);
		// 我的积分
		userintegral.setUserIntegral(new BigDecimal(0));
		// 账户状态
		userintegral.setUiStatus(1);
		// 向用户账户表插入一条记录
		super.save(userintegral);

	}
	
	/**
	 * @Title: saveUserIntegralByNum
	 * @Description: 保存到用户账户表
	 * @param reqUserLoginByNum
	 *            -用户注册请求bean
	 * @param userIntegralId
	 *            -账户id
	 * @param userLoginId
	 *            -登录id
	 * @param @return
	 * @author Li Yi
	 * @return
	 * @throws
	 */
	@Transactional(propagation = Propagation.REQUIRED)
	public void saveUserIntegralByNum(ReqUserLoginByNum reqUserLoginByNum,
			String userIntegralId, String userLoginId) {

		Userintegral userintegral = new Userintegral();
		// 为用户账户表设置主键
		userintegral.setUsId(userIntegralId);
		// 用户登录ID
		userintegral.setLoginId(userLoginId);
		// 我的积分
		userintegral.setUserIntegral(new BigDecimal(0));
		// 账户状态
		userintegral.setUiStatus(1);
		// 向用户账户表插入一条记录
		super.save(userintegral);

	}
}
